import { createSlice } from '@reduxjs/toolkit'
const initialState = {
    name: "陈岩",
    info: {
        sex: "男",
        age: 8
    }
}

export const counterSlice = createSlice({
    name: 'cy',
    initialState,
    reducers: {
        setName: (state, action) => {
            state.name = action.payload
        },
        setInfo: (state, action) => {
            state.info = action.payload
        }
    }
})
// 每个 case reducer 函数会生成对应的 Action creators
export const { setName, setInfo } = counterSlice.actions;
export const cyName = state => state.student.name;
export const cyInfo = state => state.student.info;

export default counterSlice.reducer